<?php

namespace App\Api\Http\Requests;

class UserRequest extends Request
{
    /**
     * 用户请求认证
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * 设置请求验证规则
     *
     * @return array
     */
    public function rules()
    {
        return [
            'username' => 'max:18|min:6|unique:users,username',
            'password' => 'min:6',
            'phone_number'=>array('digits:11','regex:/^0?1[3-9]\d{9}$/'),
            'email'=>'email|unique:users,email',
            'recommended' => 'min:6|max:6',
        ];
    }

    /**
     * 翻译验证属性
     *
     * @return array
     */
    public function attributes()
    {
        return [
            'username' => '用户名',
            'password' => '密码',
            'phone_number'=>'手机号码',
            'email'=>'邮箱',
            'recommended' => '推荐人编号',
        ];
    }
}